function login() {
    //拿到前台的数据
    let data = {
        username: $("#username").val(),
        password: $("#password").val(),
        code: $("#code").val()
    };
    let result = ajax("/api/se/user/login", data, "post");
    // console.log(result,"----------");
    if(result.code === 200){
        alert("登录成功！(=^ ^=)");
        //将登录成功标识存入session中
        sessionStorage.setItem("isLogin", "true");
        //将当前登录用户名存入session中
        sessionStorage.setItem("username",$("#username").val());
        //将颁发的token存入session中
        sessionStorage.setItem("token",result.data);
        /**
         * 获取当前用户id
         */
        findUserId();
        window.open(URI + "/rbac/html/manage.html", "_self");
    }else{
        layer.alert("登录失败，请重新输入！",{icon:2});
    }
}

function findUserId() {
    //得到session中的用户名
    let username = sessionStorage.getItem("username");
    let result = myAjax("/api/se/user/findUserIdByUsername",{username:username},"post");
    if(result){
        //将用户id存入session中
        sessionStorage.setItem("userId",result.data.id);
    }
}